<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <!-- BEGIN 全局样式 -->
    <link rel="stylesheet" href="../../../lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" type="text/css"/>
    <link rel="stylesheet" href="../../../lib/bootstrapvalidator/dist/css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="../../../css/reset-diy.css" type="text/css">
    <link rel="stylesheet" href="../../../lib/jedate/skin/jedate-blue.css">
    <link rel="stylesheet" href="public.css">
    <title>全日考勤时间设置</title>
</head>
<body>

<div class="container">
    <span class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> 新增</span>
    <table class="table table-bordered">
        <thead>
        <th>名称</th>
        <th>开始时间</th>
        <th>结束时间</th>
        <th>启用</th>
        <th>操作</th>
        </thead>
        <tbody>
        <tr>
            <td>课程名称</td>
            <td><input type="text" id="working_start" class="form-control" readonly name="WORKING_START"></td>
            <td><input type="text" id="working_finish" class="form-control" readonly name="WORKING_FINISH"></td>
            <td>启用</td>
            <td><span>编辑</span><span>删除</span></td>
        </tr>
        <tr>
            <td>课程名称</td>
            <td><input type="text" id="working_start" class="form-control" readonly name="WORKING_START"></td>
            <td><input type="text" id="working_finish" class="form-control" readonly name="WORKING_FINISH"></td>
            <td>启用</td>
            <td><span>编辑</span><span>删除</span></td>
        </tr>
        </tbody>
    </table>
    <!--
    <form id="form-day" class="form-horizontal" name="form-day">

        <h3 class="text-c mb-30">全日考勤时间设置</h3>
        <div class="form-group">
            <label class="control-label col-sm-3">起始时间</label>
            <div class="col-sm-6">
                <input type="text" id="working_start" class="form-control" readonly name="WORKING_START">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-3">结束时间</label>
            <div class="col-sm-6">
                <input type="text" id="working_finish" class="form-control" readonly name="WORKING_FINISH">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-3"></label>
            <div class="col-sm-6">
                <a href="javascript:void(0)" class="btn-submit btn btn-primary center-block mt-20">保存</a>
            </div>
        </div>
    </form>
    -->
</div>

<!--核心脚本sss-->
<script src="../../../lib/jquery/1.9.1/jquery.js" type="text/javascript" charset="utf-8"></script>
<!--[if lt IE 9]>
<script src="../../../js/excanvas.min.js"></script>
<script src="../../../js/respond.min.js"></script>
<![endif]-->
<!--加密插件sss 必须放在jquery.myPlugIn_v1.0.js前面-->
<script src="../../../js/common/jsrsasign-all-min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/common/crypto-js.min.js" type="text/javascript" charset="utf-8"></script>
<!--加密插件eee-->

<!--<script src="../../../js/bootstrap.min.js" type="text/javascript"></script>-->
<script src="../../../lib/layer/2.4/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../lib/jedate/dist/jedate.min.js"></script>
<script src="../../../lib/bootstrapvalidator/dist/js/bootstrapValidator.min.js"></script>
<script src="../../../js/work-box.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/common/jquery.myPlugIn_v1.0.js" type="text/javascript" charset="utf-8"></script>

<script>
    var T = new Extend_base();
    jQuery(document).ready(function () {
        function Day() {
            // this.validatorRule();
            // this.dateInit();
            // this.getDay();
            // this.submitEvent();
        }

        Day.prototype = {
            dateInit: function () {
                var _this = this;
                jeDate("#working_start", {
                    minDate: '2018-07-12 00:00:00',
                    maxDate: '2550-06-16 23:59:59',
                    format: "hh:mm:ss",
                    isClear: false,
                    donefun: function (obj) {
                        if (obj.val) {
                            _this.validatorSuccess($(obj.elem));
                        }
                    }
                });

                jeDate("#working_finish", {
                    minDate: '2018-07-12 00:00:00',
                    maxDate: '2550-06-16 23:59:59',
                    format: "hh:mm:ss",
                    isClear: false,
                    donefun: function (obj) {
                        if (obj.val) {
                            _this.validatorSuccess($(obj.elem));
                        }
                    }
                });
            },
            getDay: function () {
                var _this = this;
                T.ajaxSecret(url_join("setting/base"), "post", {}, function (res) {
                    console.log(res);
                    $("#working_start").val(res.data.WORKING_START);
                    $("#working_finish").val(res.data.WORKING_FINISH);
                });
            },
            submitEvent: function () {
                var _this = this;
                $(".btn-submit").on("click", function () {
                    // 获取表单对象
                    var form = $("#form-day");
                    form.data('bootstrapValidator').validate();

                    if (form.find(".has-error").length == 0) {
                        var data = {
                            setting: form.serializeObject()
                        };

                        T.ajaxSecret(url_join("setting/update"), "post", data, function (e) {
                            layer.msg("操作成功", {icon: 1});
                            _this.validatorNormal(form);
                        });
                    } else {
                        console.log("验证不通过");
                        return false;
                    }

                });
            },
            validatorRule: function () {
                $("#form-day").bootstrapValidator({
                    message: "This value is not valid !",
                    feedbackIcons: {
                        valid: "glyphicon glyphicon-ok",
                        invalid: "glyphicon glyphicon-remove",
                        validating: "glyphicon glyphicon-refresh"
                    },
                    fields: {
                        WORKING_START: {
                            validators: {
                                notEmpty: {
                                    message: "开始时间不能为空"
                                },
                            }
                        },
                        WORKING_FINISH: {
                            validators: {
                                notEmpty: {
                                    message: "结束时间不能为空"
                                },
                            }
                        }
                    }
                });
            },
            validatorSuccess: function (ele) {
                var group = ele.parents(".form-group");
                group.removeClass("has-error").addClass("has-success"); // 移除error样式,添加success样式
                group.find("small.help-block").remove(); // 移除提示文字
                group.find("i.glyphicon-remove").remove();
                ele.parent().append($("<i class='form-control-feedback glyphicon glyphicon-ok'></i>"))
            },
            validatorError: function (ele, text) {
                var group = ele.parents(".form-group");
                group.removeClass("has-success").addClass("has-error"); // 移除error样式,添加success样式
                group.find("i.glyphicon-ok").removeClass("glyphicon-ok").addClass("glyphicon-remove");

                var small = $("<small class='help-block'>" + text + "</small>");
                ele.parent().append(small);
            },
            validatorNormal:function (form){
                form.find(".has-error").removeClass("has-error");
                form.find(".has-success").removeClass("has-success");
                form.find("i.glyphicon-ok").removeClass("glyphicon-ok");
                form.find("i.glyphicon-remove").removeClass("glyphicon-remove");
                form.find("small.help-block").remove();
            },
            constructor: "Day",
        };

        new Day();
    });
</script>
</body>
</html>